/**
 * 实现 Promise 化的 setTimeout 函数
 * @param {Function} cb
 * @param {Number} delay
 * @param  {any} args
 * @returns Promise
 */
export const useTimeout = (cb, delay = 100, ...args) => {
  return new Promise((resolve, reject) => {
    const timer = setTimeout(() => {
      try {
        cb(...args);
        resolve(timer);
      } catch (error) {
        console.log(error);
        reject(error);
      }
    }, delay);
  })

}
